package lab_09.task4.com.acme.bankapp.service.bank;

import lab_09.task4.com.acme.bankapp.domain.bank.*;

public class BankApplication {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Bank bank = new Bank();
		
		System.out.println("Creating first client with savings account.");
		Client client1 = BankService.addClient(bank,new Client(Gender.FEMALE, "Lena", new SavingsAccount(10)));
		client1.printAllClientData();
		
		System.out.println("Adding second checking account.");
		client1.addClientAccount(new CheckingAccount(15, 10));
		client1.printAllClientData();
		
		System.out.println("Putting 6 on the first account.");
		client1.printAllClientData();
		
		System.out.println("Withdrawing 20 from the first account.");
		client1.printAllClientData();
		
		System.out.println("Withdrawing 20 from the second account.");
		client1.printAllClientData();
		
		System.out.println("Withdrawing 7 from the second account.");
		client1.printAllClientData();
		
		System.out.println("Putting 10 on the second account.");
		client1.printAllClientData();
		
		System.out.println("Withdrawing 7 from the second account.");
		client1.printAllClientData();
		
		System.out.println("Creating second client with checking account.");
		Client client2 = BankService.addClient(bank,new Client(Gender.MALE, "Oleg", new CheckingAccount(5, 5)));
		client2.printAllClientData();

// I decided not to use modifyBank and printBalance and instead to use more specific methods because
// the results in this case are more instructive to debug and to see that the program works correctly.
// I have just commented out the code with modifyBank and printBalance.
		
//		modifyBank(bank);
//		printBalance(bank);
	}
	
//	protected static void modifyBank(Bank bank) {
//		for (Client client: bank.getClients()) {
//			for (Account account: client.getAccounts()) {
//				account.deposit(0.5); //add 0.5 to each client
//				account.withdraw(0.25); //take 0.25 from each client's account	
//			}
//		}
//	}
//	
//	protected static void printBalance(Bank bank) {
//		int i = 0;
//		for (Client client: bank.getClients()) {
//			i++;
//			System.out.format("Client number %1$d (%2$s) has %3$d accounts.\n", i, client.getClientSex().getGreeting(),client.getAccounts().size());
//			int j = 0;
//			for (Account account: client.getAccounts()) {
//				j++;
//				System.out.format("Account number %1$d. Balance: %2$f.\n", j, account.getBalance());
//			}
//			System.out.println("\n");
//			
//		}
//	}
}

